package fr.inserm.umr915.libjson;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.w3c.dom.Document;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

public abstract class NilNode extends Node
	{
	static final String TAG="nil";
	NilNode()
		{
		}
	@Override
	public NodeType getNodeType()
		{
		return NodeType.NIL;
		}
	
	@Override
	public Node clone(NodeFactory owner) {
		return owner.createNilNode();
		}
	
	@Override
	public void print(PrintWriter out)
		{
		out.print("null");
		}
	
	
	@Override
	public int hashCode()
		{
		return 1;
		}	
	@Override
	public org.w3c.dom.Element asDom(Document owner)
		{
		org.w3c.dom.Element root= owner.createElement(TAG);
		return root;
		}
	
	
	
	@Override
	public void write(XMLStreamWriter out) throws XMLStreamException
		{
		out.writeEmptyElement(TAG);
		}
	
	
	@Override
	protected void saxHandler(ContentHandler handler) throws SAXException,
			IOException
		{
		handler.startElement("","", TAG, new AttributesImpl());
		handler.endElement("", "", TAG);
		}
	
	public void write(DataOutputStream out) throws IOException
		{
		out.writeByte((byte)getNodeType().ordinal());
		}
	
	
	
	
	
}
